package my_bind

import (
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	resp "study/server/model/response"
)

func MyBind[T any](myErr error, c *gin.Context) (*T, error) {
	data := new(T)
	err := c.ShouldBind(data)
	if err != nil {
		logrus.Error(err)
		resp.FailWithErrorMsg("数据格式错误", myErr, c)
		return nil, err
	}
	return data, nil
}
